﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="gaInfo_Default" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="../news/NewsTypeSelect.ascx" TagName="NewsTypeSelect" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../edit/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../edit/xheditor-zh-cn.src.js"></script>
    <script src="../js/jquery-ui-1.7.3.custom.min.js" language="javascript" type="text/javascript"></script>
    <script type="text/javascript">
        var selectValue = new Array();
        $(document).ready(function () {


            $("#btnImport").click(function () {
                if ($("[name=select]").serialize() == "") {
                    alert("请选择新闻");
                    return false;
                }
                $('#dialog').dialog('open');
                return false;
            })
            $("#cbkAll").click(function () {
                var chks = $("input[tt=aa]");
                for (var i = 0; i < chks.length; i++) {
                    chks[i].checked = this.checked;
                }
            })
            $('#dialog').dialog({
                autoOpen: false,
                modal: true,
                width: 600,
                buttons: {
                    "取消": function () {
                        var chks = $("#DataList1 input[type=checkbox]");
                        for (var i = 0; i < chks.length; i++) {
                            chks[i].checked = false;
                            for (var j = 0; j < selectValue.length; j++) {
                                if (chks[i].value == selectValue[j]) {
                                    chks[i].checked = true;
                                }
                            }
                        }
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var chks = $("#DataList1 input[type=checkbox]");
                        $("#lblSelectType").html('');
                        var txt = '';
                        var val = "";
                        for (var i = 0; i < chks.length; i++) {
                            var chk = chks[i]
                            if (chk.checked) {
                                txt += $(chk).parent().children("label").html() + ",";
                                val += $(chk).val() + ",";
                            }
                        }
                        if (val.length > 0) {
                            val = val.substring(0, val.length - 1);
                            $("#hidSelectValue").val(val);
                        }
                        $.post("Handler.ashx", $("input").serialize(), function (data) {
                            if (data == "true") {
                                alert("导入成功");
                               document.location = document.location;
                            }
                            else {
                                alert(data);
                            }
                        })
                        $(this).dialog("close");
                    }
                }
            });
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidSelectValue" runat="server" />
    <div class="button_bar">
        <asp:DropDownList 
            ID="ddlNewsStep" runat="server">
        </asp:DropDownList>
&nbsp;<asp:Button ID="btnImport" CssClass="common_button" runat="server" Text="导入" />
    </div>
    <div>
        <input id="hidIds" type="hidden" runat="server" />
        <table class="data_list_table">
            <tr>
                <th>
                    <input id="cbkAll" type="checkbox" />
                    全选
                </th>
                <th>
                    编号
                </th>
                <th>
                    标题
                </th>
                <th>
                    创建时间
                </th>
                <th>
                    操作
                </th>
            </tr>
            <asp:Repeater ID="Repeater1" runat="server">
                <ItemTemplate>
                    <tr>
                        <td class="list_data_number">
                            <input name="select" value='<%# Eval("N_id") %>' type="checkbox" tt="aa" id="select"
                              />
                        </td>
                        <td class="list_data_number">
                            <%# Eval("N_id")%>
                        </td>
                        <td class="list_data_text">
                            <%# Eval("N_title")%>
                        </td>
                        <td class="list_data_text">
                            <%# Eval("N_cTime", "{0:yyyy-MM-dd HH:mm:ss}")%>
                        </td>
                        <td class="list_data_ltext">
                            <a href='edit.aspx?id=<%# Eval("N_id") %>&page=<%=GetPage() %>'>
                                <img src="../images/bt_edit.gif" alt="修改" title="修改" /></a> <a href='delete.aspx?id=<%# Eval("N_id") %>&page=<%=GetPage() %>'
                                    onclick="return confirm('确定删除？')">
                                    <img src="../images/bt_del.gif" alt="删除" />
                                </a>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
            <tr>
                <th colspan="5" class="pager">
                    <div class="pager">
                        <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="10" UrlPaging="True"
                            OnPageChanged="AspNetPager1_PageChanged" OnPageChanging="AspNetPager1_PageChanging">
                        </webdiyer:AspNetPager>
                    </div>
                </th>
            </tr>
        </table>
    </div>
    <div id="dialog" title="提示消息" style="display:none">
        <p id="content" style="text-align: center">
            <asp:DataList ID="DataList1" runat="server" 
                onitemdatabound="DataList1_ItemDataBound">
                <ItemTemplate>
                    <uc1:NewsTypeSelect ID="NewsTypeSelect1" runat="server" Pid='<%# Eval("id") %>'/>
                </ItemTemplate>
                
            </asp:DataList>
          </p>
    </div>
    </form>
</body>
</html>
